<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>元素水平垂直居中</title>
    <style>
        .outer {
            height: 400px;
            width: 400px;
            background-color: bisque;
            margin: 0 auto;
          
            /* 方案一：定位+变换 */
            /* position: relative; */

            /* 方案二：flex布局+margin：auto */
            /* display: flex; */

            /* 方案三：flex布局 */
            /* display: flex;
            justify-content: center;
            align-items: center; */

        }
        .inner {
            height: 200px;
            width: 200px;
            background-color: skyblue;
            

            /* 方案一：定位+变换 */
            /* position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%); */

            /* 方案二：flex布局+margin：auto */
            /* margin: auto; */
        }

    </style>
</head>
<body>
    <div class="outer">
        <div class="inner">块元素</div>
    </div>
    <br>
    <!-- <div class="outer">
        <span class="inner">行内元素</span>
    </div> -->
</body>
</html>